import tkinter as tk

def close_window():
    window.destroy()

if __name__ == '__main__':
    window = tk.Tk()

    # 创建按钮
    button = tk.Button(window, text="Close Window", command=close_window)
    button.pack()

    window.mainloop()
    window2 = tk.Tk()

    # 创建按钮
    button = tk.Button(window2, text="Close Window", command=close_window)
    button.pack()

    window2.mainloop()